/*
* @Author: ZHELIHAO\fangshuqin
* @Date:   2018-05-21 11:36:25
* @Last Modified by:   ZHELIHAO\fangshuqin
* @Last Modified time: 2018-05-25 11:39:30
*/
{
	let EVENT_CLICK = Laya.Event.CLICK;

    class Shop extends Sail.Scene {
        constructor () {
            super();
            this.header = null;
            this.shopdetail =null;
            this.bg = null;

            this.init();
        }

        init() {
            Public.BetAndSet.I.exit();
        	let btnBack = new Laya.Image("res/public/btn_back.png");
                btnBack.on(EVENT_CLICK, this, this.goback);
                btnBack.left = 40;
                btnBack.top = 15;

            let tips = new Laya.Image("res/shop/title.png");
            	tips.left = 135;
            	tips.top = 17;

            // this.betandset = Public.BetAndSet.getInstance();
            this.shopdetail = new Com.Shop.Shopdetail();
            this.bg =  new Laya.Image("res/hall/bg.jpg");
            this.bg.centerX = 0;
            this.bg.centerY = 0;
            this.addChildren( this.bg, Public.BetAndSet.I, this.shopdetail, btnBack, tips );

            this.registerActions();
            Sail.io.emit(GAME_CMDS.USE_INFO);
        }

        registerActions() {
          this.ACTIONS = {
                 [GAME_CMDS.USE_INFO]  : this.getUserInfo,
            };
            Sail.io.register(this.ACTIONS, this);
        }

        getUserInfo(data) {
           Public.BetAndSet.I.getUserInfo(data); 
        }

        goback () {
            Public.BetAndSet.I.exit();
            
            Laya.loader.load(ASSETS.HALL, Laya.Handler.create(null, function () {
                Sail.director.runScene(new Scene.Hall);
            }));
        }

        onExit () {
        	Sail.io.unregister(this.ACTIONS);
        	this.shopdetail.exit();
        }

        onResize (width, height) {
            let rate = height / GAME_CONFIG.HEIGHT;

            this.tab.resize(width, height, rate);
            this.battle.resize(width, height, rate);
        }
    }

    Sail.class(Shop, "Scene.Shop");
}